#include <math.h>
#include <iostream>

#include "dna.h"

Dna::Dna ( int pregnanceDuration, QColor color ) : QObject()
{
	this -> pregnanceDuration = pregnanceDuration;
	this -> color = color;

	srand(rand());
	maxAge = ( ( rand() % 50 ) + 50 );
	srand(rand());
	maxSpeed = ( ( rand() % 40 ) + 10 ) / 10;
	srand(rand());
	viewDistance = ( rand() % 50 ) + 15;
	srand(rand());
	attackStrength = ( ( rand() % 15 ) + 5 ) / 10;
	srand(rand());
	waitWillingness = ( rand() % 100 );
}

Dna::Dna ( Dna* old )
{
	pregnanceDuration = old -> getPregnanceDuration();
	color = old -> getColor();

	srand(rand());
	maxAge = ( old -> getMaxAge() ) * ( 0.9 + ( ( float ) ( rand() % 3 ) / 10 ) );
	srand(rand());
	maxSpeed = ( old -> getMaxSpeed() ) * ( 0.9 + ( ( float ) ( rand() % 3 ) / 10 ) );
	srand(rand());
	viewDistance = ( old -> getViewDistance() ) * ( 0.9 + ( ( float ) ( rand() % 3 ) / 10 ) );
	srand(rand());
	attackStrength = ( old -> getAttackStrength() ) * ( 0.9 + ( ( float ) ( rand() % 3 ) / 10 ) );
	srand(rand());
	waitWillingness = ( old -> getWaitWillingness() ) * ( 0.9 + ( ( float ) ( rand() % 3 ) / 10 ) );
}

int Dna::getPregnanceDuration()
{
	return pregnanceDuration;
}

float Dna::getMaxAge()
{
	return maxAge;
}

float Dna::getViewDistance()
{
	return viewDistance;
}

float Dna::getMaxSpeed()
{
	return maxSpeed;
}

float Dna::getAttackStrength()
{
	return attackStrength;
}

float Dna::getWaitWillingness()
{
	return waitWillingness;
}

QColor Dna::getColor()
{
	return color;
}

void Dna::setColor ( QColor color )
{
	this -> color = color;
}
